﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DataProviderService
{
    internal class DTOConverter
    {
        public static readonly DTOConverter Instance = new DTOConverter();

        internal DTO.Person CreatePerson()
        {
            return new DTO.Person();
        }

        internal DTO.Student CreateStudent()
        {
            return new DTO.Student();
        }



        internal DTO.Prepod CreatePrepod(Prepod s)
        {
            return new DTO.Prepod
            {
                Idprep = (int)s.nCode,
                person = DTOConverter.Instance.CreatePerson(s.Person)
            };
        }

        internal DTO.Person CreatePerson(Person person)
        {
            return new DTO.Person
                {
                    IDPerson = (int)person.nCode,
                    LastName = person.Cfirstname,
                    FirstName = person.Clastname,
                    Patronymic = person.Cotch
                };
        }

        internal DTO.Student CreateStudent(Student s)
        {
            return new DTO.Student
            {
                Idstud = (int)s.nCode,
                zach = DTOConverter.Instance.CreateZach(s),
                person = DTOConverter.Instance.CreatePerson(s.Person)

            };
        }

        internal DTO.Zachet CreateZach(Student s)
        {
            return new DTO.Zachet
                {
                    Idstud = s.nCode,
                    IdZach = s.Zaches.Select(s1 => s1.Ik_zach).First(),
                    nZach = s.Zaches.Select(s1 => s1.Nn_zach).First(),
                };
        }



        internal DTO.Semestr CreateSemestr(Semester s)
        {
            return new DTO.Semestr{SemNum = s.n_sem};
        }

        internal DTO.Work CreateteWork()
        {
            throw new NotImplementedException();
        }

        internal DTO.RefReq CreateRefReq(RefReq s)
        {
            return new DTO.RefReq
            {
                IdRefReq = s.Ik_RefReq,
                nameReq = s.NameReq
            };
        }
    }
}